package com.iraeta.dao.main.sys;

import com.iraeta.entity.main.Role;
import com.iraeta.entity.main.RolePermission;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RoleDao {
    int insert(Role record);

    int updateByPrimaryKey(Role record);

    int deleteByPrimaryKey(Integer id);

    Role selectByPrimaryKey(Integer id);

    List<Role> selectByRoleName(@Param("roleName") String roleName);
    List<Role> selectByPermissionId(@Param("permissionId") Integer permissionId);
    /*userRole  user set role*/
    //user 选择一个角色用
    List<Role> selectAllRole();
    List<Role> selectRoleByUserId(@Param("userId") Integer userId);

    /*userRole role set user*/
    void deleteUserRoleIdStr(@Param("roleId") Integer roleId, @Param("userRoleIdStr") String userRoleIdStr); //删除userId的 不在userRoleIdStr中的数据

    //role permission用
    List<Integer> selectRolePermission(@Param("roleId") Integer roleId);
    int insertRolePermission(RolePermission rolePermission);
    RolePermission selectByRolePermission(@Param("roleId") Integer roleId, @Param("permissionId") Integer permissionId);
    void deleteRolePermissionIdStr(@Param("roleId") Integer roleId, @Param("rolePermissionIdStr") String rolePermissionIdStr);
}